# Initialise and return the datastore

import sqlite

con = sqlite.connect('/tmp/index.db')
cur = con.cursor()
 
# Test if the tables exist
# 
# file_list
cur.execute("select * from sqlite_master where type='table' and name='file_list';")
if cur.rowcount == 0:
	cur.execute("create table directory_list (directory_id integer primary key, directory_name varchar(255), directory_parent integer)")
	cur.execute("create table file_list (file_id integer primary key, file_name varchar(255), directory_id integer, file_mtime integer)")
	cur.execute("create table word_list (word_id integer primary key, word varchar(255))")
	cur.execute("create table word_file (match_id integer primary key, word_id integer, file_id integer)")

